package cn.stylefeng.guns.modular.course.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.course.entity.Course;
import cn.stylefeng.guns.modular.course.model.params.CourseParam;
import cn.stylefeng.guns.modular.course.service.CourseService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.kernel.model.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


/**
 * 上课记录表控制器
 *
 * @author liuqiang
 * @Date 2020-02-09 14:29:26
 */
@RestController
@RequestMapping("/course")
public class CourseController extends BaseController {

    @Autowired
    private CourseService courseService;

    /**
     * 新增接口
     *
     * @author liuqiang
     * @Date 2020-02-09
     */
    @PostMapping("/addItem")
    public ResponseData addItem(@RequestBody CourseParam courseParam) {
        this.courseService.add(courseParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author liuqiang
     * @Date 2020-02-09
     */
//    @RequestMapping("/editItem")
//    @ResponseBody
    public ResponseData editItem(CourseParam courseParam) {
        this.courseService.update(courseParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author liuqiang
     * @Date 2020-02-09
     */
//    @RequestMapping("/delete")
//    @ResponseBody
    public ResponseData delete(CourseParam courseParam) {
        this.courseService.delete(courseParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author liuqiang
     * @Date 2020-02-09
     */
//    @RequestMapping("/detail")
//    @ResponseBody
    public ResponseData detail(CourseParam courseParam) {
        Course detail = this.courseService.getById(courseParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author liuqiang
     * @Date 2020-02-09
     */
    @GetMapping("/list")
    public LayuiPageInfo list(CourseParam courseParam) {
        return this.courseService.findPageBySpec(courseParam);
    }

}


